from flask import Flask
from flaskLogin.extensions import bootstrap, csrf, db, login_manager
from flaskLogin.sign import sign_bp
from flaskLogin.settings import BaseConfig


def create_app():
    app = Flask('flaskLogin')
    app.config.from_object(BaseConfig)
    register_extensions(app)
    register_blueprints(app)
    return app


def register_extensions(app):  # 初始化扩展
    bootstrap.init_app(app)
    csrf.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)


def register_blueprints(app):  # 注册蓝图
    app.register_blueprint(sign_bp, url_prefix='/')
